package cn.bsuc.crm.controller;


import cn.bsuc.crm.annotation.WebLog;
import cn.bsuc.crm.dto.QueryLogParamsDTO;
import cn.bsuc.crm.service.LogService;
import cn.bsuc.crm.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuoyuan
 * @since 2022-10-03
 */
@RestController
@RequestMapping("/log")
@CrossOrigin
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * 分页查询
     * @param queryLogParamsDTO
     * @return
     */
    @GetMapping("findAll")
    public Result findAllLog(QueryLogParamsDTO queryLogParamsDTO){
        return logService.findAllLog(queryLogParamsDTO);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @WebLog(module = "操作日志",opt = "批量删除日志")
    @PostMapping("delete")
    public Result deleteLog(@RequestBody Integer[] ids){
        return logService.deleteLog(ids);
    }

    /**
     * 清空
     * @return
     */
    @WebLog(module = "操作日志",opt = "清空日志")
    @GetMapping("clean")
    public Result cleanLog(){
        return logService.cleanLog();
    }

    /**
     * 导出日志 为 excel 表
     * @param response
     * @return
     */
    @WebLog(module = "操作日志",opt = "导出日志")
    @GetMapping("exportLog")
    public Result exportLog(HttpServletResponse response){
        return logService.exportLog(response);
    }


}

